﻿@model JCTimes.DomainModel.Entity.PDA
@{
    ViewBag.Title = "PDA添加";
    var roleid = SessionHelper.CurrUser.RoleID;
}

@Styles.Render("~/Content/forms")
@using (Ajax.BeginForm(new AjaxOptions { OnSuccess = "GetMsg" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        @Html.HiddenFor(u => Model.ID)
       
       @if (roleid == Constant.Admin)
       {
        <div class="editor-label">
            @Html.LabelFor(model => model.CreateUsersID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.CreateUsersID, new DropDownList(DropDownListType.Agency), "--请选择--")
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.UsersID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.UsersID, new DropDownList(DropDownListType.Empty))
        </div>
       }
       else
       {
           <div class="editor-label">
            @Html.LabelFor(model => model.UsersID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.UsersID, new DropDownList(DropDownListType.Account), "--请选择--")
        </div>
       }
            <div class="editor-label">
            <table>
            @for (int i = 0; i < 15; i++)
        {
            <tr >
            <td style="height:25px">PDA编号：<input id="PDANo_@i" name="PDANo"/></td>
            <td>用途：<input id="Purpose_@i" name="Purpose"/></td>
            </tr>
                }
            </table>
        </div>
        <p style="text-align: center">
            <input class="button" type="submit" value="提交" />
        </p>
    </fieldset>
}
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
     @Scripts.Render("~/bundles/jqueryui")
    @Scripts.Render("~/bundles/cascade")
    <script type="text/javascript">
        function GetMsg(data)
        {
            //alert(data.Msg);
            if (data.IsSuccess)
            {
                if (confirm('添加成功，继续添加PDA？'))
                {
                    window.location.href = '@Url.Action("Create")';
                }
                else
                {
                    window.location.href = '@Url.Action("Index")';
                }
            }
        }

        $(function ()
        {
            $("#CreateUsersID").cascade({
                source: '@Url.Action("GetAccount", "Account")',
                cascaded: 'UsersID',
                disableUntilLoaded: true
            });
        }); 
    </script>
}